<template>
  <transition name="el-zoom-in-center">
    <div class="jsbos-preview-main">
      <div class="jsbos-common-page-header">
        <el-page-header @back="goBack" content="详情" />
        <div class="options">
          <el-button @click="goBack">取 消</el-button>
        </div>
      </div>
      <el-row
        :gutter="15"
        class="main jsbos-row-style"
        :style="{ margin: '0 16px', width: '1200px' }"
      >
        <el-form
          v-loading="loading"
          ref="elForm"
          :model="dataForm"
          size="small"
          label-width="100px"
          label-position="right"
        >
          <template v-if="!loading">
            <el-col :span="24"
              >taskDynamics
              <groupTitle content-position="left" content="基本信息">
              </groupTitle>
            </el-col>
            <el-col :span="12">
              <el-form-item label="计划名称" prop="name">
                <p>{{ dataForm.name }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关联需求征集" prop="demandCollectId">
                <p>{{ dataForm.demandCollectId }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="关联需求" prop="demandId">
                <p>{{ dataForm.demandId }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="主办单位" prop="organizer">
                <p>{{ dataForm.organizer }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="承办单位" prop="organizerBy">
                <p>{{ dataForm.organizerBy }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="开始时间" prop="startDatetime">
                <p>{{ jsbos.dateFormat(dataForm.startDatetime) }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="截至时间" prop="endDatetime">
                <p>{{ jsbos.dateFormat(dataForm.endDatetime) }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="培训预算" prop="budget">
                <p>{{ dataForm.budget }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="计划类型" prop="type">
                <p>{{ dataForm.type | dynamicText(typeOptions) }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="描述" prop="description">
                <p>{{ dataForm.description }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24"
              >taskDynamics
              <groupTitle content-position="left" content="附件"> </groupTitle>
            </el-col>
            <el-col :span="24">
              <el-form-item label="附件" prop="files">
                <UploadFz
                  v-model="dataForm.files"
                  disabled
                  detailed
                  :fileSize="5"
                  sizeUnit="MB"
                  :limit="9"
                  buttonText="点击上传"
                >
                </UploadFz>
              </el-form-item>
            </el-col>
            <el-col :span="24"
              >taskDynamics
              <groupTitle content-position="left" content="计划明细">
              </groupTitle>
            </el-col>
            <el-col :span="24">
              <el-form-item label-width="0">
                <div class="jsbos-common-title">
                  <h2>设计子表</h2>
                </div>
                <el-table :data="dataForm.temsplandetailList" size="mini">
                  <el-table-column
                    type="index"
                    width="50"
                    label="序号"
                    align="center"
                  />
                  <el-table-column prop="name" label="培训名称">
                    <template slot-scope="scope">
                      <p>{{ scope.row.name }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="budget" label="培训预算">
                    <template slot-scope="scope">
                      <p>{{ scope.row.budget }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="startDatetime" label="开始时间">
                    <template slot-scope="scope">
                      <p>{{ jsbos.dateFormat(scope.row.startDatetime) }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="endDatetime" label="截至时间">
                    <template slot-scope="scope">
                      <p>{{ jsbos.dateFormat(scope.row.endDatetime) }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="address" label="培训地点">
                    <template slot-scope="scope">
                      <p>{{ scope.row.address }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="lecturerUserId" label="讲师">
                    <template slot-scope="scope">
                      <p>{{ scope.row.lecturerUserId }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="curator" label="负责人">
                    <template slot-scope="scope">
                      <p>{{ scope.row.curator }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="courseFaceId" label="面授课程">
                    <template slot-scope="scope">
                      <p>{{ scope.row.courseFaceId }}</p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="sourceFunding" label="经费来源">
                    <template slot-scope="scope">
                      <p>
                        {{
                          scope.row.sourceFunding
                            | dynamicText(sourceFundingOptions)
                        }}
                      </p>
                    </template>
                  </el-table-column>
                  <el-table-column prop="classHour" label="课时">
                    <template slot-scope="scope">
                      <p>{{ scope.row.classHour }}</p>
                    </template>
                  </el-table-column>
                </el-table>
              </el-form-item>
            </el-col>
            <el-col :span="24"
              >taskDynamics
              <groupTitle content-position="left" content="计划监督人">
              </groupTitle>
            </el-col>
            <el-col :span="24">
              <el-form-item label="监督人" prop="supervisor">
                <p>{{ dataForm.supervisor }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="扩展字段" prop="extendFields">
                <p>{{ dataForm.extendFields }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="状态" prop="enabledMark">
                <p>{{ dataForm.enabledMark }}</p>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="实施状态" prop="enforceMark">
                <p>
                  {{ dataForm.enforceMark | dynamicText(enforceMarkOptions) }}
                </p>
              </el-form-item>
            </el-col>
          </template>
        </el-form>
      </el-row>
    </div>
  </transition>
</template>
<script>
import request from "@/utils/request";
import PrintBrowse from "@/components/print-browse/index.vue";
import jsbos from "@/utils/jsbos";

export default {
  components: { PrintBrowse },
  props: [],
  data() {
    return {
      visible: false,
      loading: false,
      printBrowseVisible: false,
      printId: "",
      dataForm: {
        id: "",
        name: "",
        demandCollectId: "",
        demandId: "",
        organizer: "",
        organizerBy: "",
        startDatetime: "",
        endDatetime: "",
        budget: "",
        type: "",
        description: "",
        files: [],
        supervisor: [],
        extendFields: "",
        enabledMark: 0,
        enforceMark: "10",
        creatorTime: "",
        creatorUserId: "",
        lastModifyUserId: "",
        lastModifyTime: "",
        temsplandetailList: [],
      },
      typeOptions: [
        { fullName: "年度", id: "1" },
        { fullName: "月度", id: "2" },
        { fullName: "季度", id: "3" },
      ],
      enforceMarkOptions: [
        { fullName: "待实施", id: "10" },
        {
          fullName: "实施中",
          id: "20",
        },
        { fullName: "已实施", id: "30" },
        { fullName: "已归档", id: "40" },
      ],

      sourceFundingOptions: [
        { fullName: "教育经费", id: "1" },
        { fullName: "行政经费", id: "2" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      _dataAll.files = _dataAll.files ? JSON.parse(_dataAll.files) : [];
      for (let i = 0; i < _dataAll.temsplandetailList.length; i++) {
        var _list = _dataAll.temsplandetailList[i];
        _list.startDatetime = _list.startDatetime
          ? jsbos.dateFormat(_list.startDatetime)
          : "";
        _list.endDatetime = _list.endDatetime
          ? jsbos.dateFormat(_list.endDatetime)
          : "";
      }
      this.dataForm = _dataAll;
    },

    goBack() {
      this.$emit("refresh");
    },
    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true;
          request({
            url: "/api/course/TemsPlan/detail/" + this.dataForm.id,
            method: "get",
          }).then((res) => {
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.jsbos-row-style {
  padding: 10px 10px 10px 0;

  > .el-row {
    margin: 0 !important;
    padding: 0 16px;
  }

  .el-row:nth-child(0) {
    padding: 0px !important;
  }

  > .el-col {
    padding: 0px !important;

    .el-form-item {
      margin-bottom: -1px !important;
      margin-right: -1px;
      border: 1px solid var(--border-4) !important;
      background-color: var(--light-blue) !important;
    }

    .el-form-item__label {
      line-height: 38px;
      height: 100%;
    }

    .el-form-item__content {
      line-height: 38px;
      padding-left: 20px;
      background-color: var(--white) !important;
      border-left: 1px solid var(--border-4) !important;
    }
  }
}
</style>
